#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>


int main(int argc, const char *argv[])
{
	mkfifo("./pipe1",0664);
	mkfifo("./pipe2",0664);

	int fd1=open("./pipe1",O_RDWR);
	int fd2=open("./pipe2",O_RDWR);

	pid_t pid=fork();

	if(pid>0)
	{
		while(1)
		{
			char mybuf[32]={0};
			printf("plzinput\n");
			scanf("%s",mybuf);
			printf("yifasong:%s",mybuf);
			write(fd1,mybuf,strlen(mybuf));
//			memset(mybuf,32,0);
		}
	}
	else if(pid==0)
	{
		while(1)
		{
			char readbuf[32]={0};
			while(read(fd2,readbuf,32)>0)
			{
				printf("2:%s\n",readbuf);
			}
//			memset(readbuf,32,0);
		}
	}
	
	return 0;
}
